Package | ch.fhir.ig.cda-fhir-maps |
Type | StructureMap |
Id | Id |
FHIR Version | R4 |
Source | http://fhir.ch/ig/cda-fhir-maps/http://fhir.ch/ig/cda-fhir-maps/StructureMap-CdaChEmedToBundle.html |
Url | http://fhir.ch/ig/cda-fhir-maps/StructureMap/CdaChEmedToBundle |
Version | 0.3.0 |
Status | draft |
Date | 2022-02-11T11:14:39+01:00 |
Name | CdaChEmedToBundle |
Experimental | False |
Realm | ch |
Authority | hl7 |
Description | Medication Entries 2020-10-30 Oliver Egger, copyright ahdis ag, Apache License CDA-CH-EMED: https://art-decor.org/art-decor/decor-project--cdachemed- FHIR CH-EMED: http://fhir.ch/ig/ch-emed/index.html |
Copyright | CC-BY-SA-4.0 |
No resources found
No resources found
Note: links and images are rebased to the (stated) source
map "http://fhir.ch/ig/cda-fhir-maps/StructureMap/CdaChEmedToBundle" = "CdaChEmedToBundle" // Medication Entries // 2020-10-30 Oliver Egger, copyright ahdis ag, Apache License // CDA-CH-EMED: https://art-decor.org/art-decor/decor-project--cdachemed- // FHIR CH-EMED: http://fhir.ch/ig/ch-emed/index.html uses "http://hl7.org/fhir/cda/StructureDefinition/ClinicalDocument" alias ClinicalDocument as source uses "http://hl7.org/fhir/cda/StructureDefinition/AssignedAuthor" alias AssignedAuthor as source uses "http://hl7.org/fhir/cda/StructureDefinition/AssignedEntity" alias AssignedEntity as source uses "http://hl7.org/fhir/cda/StructureDefinition/Author" alias Author as source uses "http://hl7.org/fhir/cda/StructureDefinition/CustodianOrganization" alias CustodianOrganization as source uses "http://hl7.org/fhir/cda/StructureDefinition/IVL_TS" alias IVL_TS as source uses "http://hl7.org/fhir/cda/StructureDefinition/EIVL_TS" alias EIVL_TS as source uses "http://hl7.org/fhir/cda/StructureDefinition/Observation" alias Observation as source uses "http://hl7.org/fhir/cda/StructureDefinition/PatientRole" alias PatientRole as source uses "http://hl7.org/fhir/cda/StructureDefinition/RecordTarget" alias RecordTarget as source uses "http://hl7.org/fhir/cda/StructureDefinition/Section" alias Section as source uses "http://hl7.org/fhir/cda/StructureDefinition/SubstanceAdministration" alias SubstanceAdministration as source uses "http://hl7.org/fhir/cda/StructureDefinition/SXPR_TS" alias SXPR_TS as source uses "http://hl7.org/fhir/StructureDefinition/Bundle" alias Bundle as target uses "http://hl7.org/fhir/StructureDefinition/Composition" alias Composition as produced uses "http://hl7.org/fhir/StructureDefinition/Patient" alias Patient as produced uses "http://hl7.org/fhir/StructureDefinition/Practitioner" alias Practitioner as produced uses "http://hl7.org/fhir/StructureDefinition/Organization" alias Organization as produced uses "http://hl7.org/fhir/StructureDefinition/MedicationStatement" alias MedicationStatement as produced uses "http://hl7.org/fhir/StructureDefinition/Dosage" alias Dosage as produced uses "http://hl7.org/fhir/StructureDefinition/Observation" alias Observation as produced imports "http://fhir.ch/ig/cda-fhir-maps/StructureMap/CdaToFhirTypes" imports "http://fhir.ch/ig/cda-fhir-maps/StructureMap/CdaToBundle" imports "http://fhir.ch/ig/cda-fhir-maps/StructureMap/CdaChToBundle" // source: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.2 // target: Annotation note (e.g. http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationstatement.html) group AnnotationComment(source section : Section, source act : Act, target note : Annotation) { act.text as text then { text.data as data -> note.text = data "level3"; text.reference as reference then { reference.value as value -> note.extension as ext then NarrativeLink(value, ext) "narrativeLink"; }; }; } // source: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.33 // target: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationdispense.html group ManufacturedMaterialEntryContentModuleDispense(source src : Supply, target medicationDispense : MedicationDispense, target medication : Medication) { src -> medication.id = 'med', medicationDispense.medication = create('Reference') as vt, vt.reference = '#med' "medication"; // quantity value (number of packages) src.quantity as quantity -> medicationDispense.quantity as medDispQuantity then { // IHE-DIS: If the product-element contains package information, the unit attribute is not be present quantity.value as value -> medDispQuantity.value = value; // IHE-DIS: If the product-element does not contain package information, the unit attribut is present and the value SHALL be out of the UCUM code system quantity.unit as unit then { unit -> medDispQuantity.unit = unit "unit"; unit -> medDispQuantity.system = 'http://unitsofmeasure.org' "ucum"; unit -> medDispQuantity.code = unit "code"; }; }; src.product as product then { product.manufacturedProduct as manufacturedProduct then { manufacturedProduct.manufacturedMaterial as manufacturedMaterial then { manufacturedMaterial.name as name where asContent.exists() = false -> medication.code as fhircode, fhircode.text = (%manufacturedMaterial.name.other) "code"; manufacturedMaterial.asContent as asContent then { asContent.containerPackagedMedicine as containerPackagedMedicine then { containerPackagedMedicine.code as code -> medication.code as fhircode share medcode then CECodeableConcept(code, fhircode); containerPackagedMedicine.name as name -> medication.code as fhircode share medcode then { name -> fhircode.text = (%name.other) "text"; } "text"; containerPackagedMedicine.formCode as formCode -> medication.form as form then CECodeableConcept(formCode, form); // Package size containerPackagedMedicine.capacityQuantity as capacityQuantity -> medication.amount = create('Ratio') as ratio, ratio.denominator = create('Quantity') as denominator, denominator.value = '1', denominator.unit = 'Package', denominator.system = 'http://unitsofmeasure.org', denominator.code = '{Package}', ratio.numerator = create('Quantity') as quantity then EmedPQQuantity(capacityQuantity, quantity); }; }; manufacturedMaterial.ingredient as ingredient -> medication.ingredient as ing then { ingredient.quantity as quantity -> ing.strength = create('Ratio') as strength then EmedRTOPQPQRatio(quantity, strength) "strength"; ingredient.ingredient as medingredient then { medingredient.code as code -> ing.item = create('CodeableConcept') as ingcode, ingcode.text = (%medingredient.name.other) then CECodeableConcept(code, ingcode) "ingredientCode"; }; }; }; }; // dosage for normal dosing, as no sequences are present there src.entryRelationship as entry then { entry.substanceAdministration as substanceAdministration then { substanceAdministration where $this.entryRelationship.sequenceNumber.exists() = false -> medicationDispense.dosageInstruction as dosage then DosageInstructionsStartStopFrequency(substanceAdministration, dosage) "dosage"; }; } "entry"; }; } group EmedPQQuantity(source src : PQ, target tgt : Quantity) { src.value as value -> tgt.value = value; src.unit as unit -> tgt.code = unit; src.unit as unit -> tgt.system = ('http://fhir.ch/ig/ch-emed/ValueSet/UnitCode'.resolve().compose.include.where(concept.where(code = %unit)).system); src.unit as unit -> tgt.unit = ('http://fhir.ch/ig/ch-emed/ValueSet/UnitCode'.resolve().compose.include.concept.where(code = %unit).display); } group EmedRTOPQPQRatio(source src : RTO_PQ_PQ, target tgt : Ratio) { src.numerator as numerator -> tgt.numerator as targetNumerator then EmedPQQuantity(numerator, targetNumerator); src.denominator as denominator -> tgt.denominator as targetDenominator then EmedPQQuantity(denominator, targetDenominator); } // source: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.33 // target: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationstatement.html group ManufacturedMaterialEntryContentModuleStatement(source src : SubstanceAdministration, target medicationStatement : MedicationStatement, target medication : Medication) { src -> medication.id = 'med', medicationStatement.medication = create('Reference') as vt, vt.reference = '#med' "medication"; src.consumable as consumable then { consumable.manufacturedProduct as manufacturedProduct then { manufacturedProduct.manufacturedMaterial as manufacturedMaterial then { manufacturedMaterial.name as name where asContent.exists() = false -> medication.code as fhircode, fhircode.text = (%manufacturedMaterial.name.other) "code"; manufacturedMaterial.asContent as asContent then { asContent.containerPackagedMedicine as containerPackagedMedicine then { containerPackagedMedicine.code as code -> medication.code as fhircode share medcode then CECodeableConcept(code, fhircode); containerPackagedMedicine.name as name -> medication.code as fhircode share medcode then { name -> fhircode.text = (%name.other) "text"; } "text"; containerPackagedMedicine.formCode as formCode -> medication.form as form then CECodeableConcept(formCode, form); // Package size containerPackagedMedicine.capacityQuantity as capacityQuantity -> medication.amount = create('Ratio') as ratio, ratio.denominator = create('Quantity') as denominator, denominator.value = '1', denominator.unit = 'Package', denominator.system = 'http://unitsofmeasure.org', denominator.code = '{Package}', ratio.numerator = create('Quantity') as quantity then EmedPQQuantity(capacityQuantity, quantity); }; }; manufacturedMaterial.ingredient as ingredient -> medication.ingredient as ing then { ingredient.quantity as quantity -> ing.strength = create('Ratio') as strength then EmedRTOPQPQRatio(quantity, strength) "strength"; ingredient.ingredient as medingredient then { medingredient.code as code -> ing.item = create('CodeableConcept') as ingcode, ingcode.text = (%medingredient.name.other) then CECodeableConcept(code, ingcode) "ingredientCode"; }; }; }; }; // dosage for normal dosing, as no sequences are present there src where $this.entryRelationship.sequenceNumber.exists() = false -> medicationStatement.dosage as dosage then DosageInstructionsStartStopFrequency(src, dosage) "dosage"; }; } // source: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.34 // target: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationstatement.html group MedicationTreatmentPlanItemEntryContentModule(source section : Section, source src : SubstanceAdministration, source patient : Patient, target medicationStatement : MedicationStatement) { // src.templateId as template then TemplateID(template, medicationStatement) "templateId"; src.id -> medicationStatement.identifier; patient -> medicationStatement.subject = create('Reference') as reference, reference.reference = ('urn:uuid:' + %patient.id) "patient"; src -> medicationStatement.status = 'completed' "completed"; src.text as text then { text.reference as reference then { reference.value as value -> medicationStatement.extension as ext then NarrativeLink(value, ext) "narrativeLink"; }; }; src -> medicationStatement.contained = create('Medication') as medication then ManufacturedMaterialEntryContentModuleStatement(src, medicationStatement, medication) "medication"; src.entryRelationship as entry where typeCode = 'RSON' then { entry.observation as observation -> medicationStatement.reasonCode as reasonCode then TreatmentReasonEntryContentModule(section, observation, reasonCode) "reasonCode"; } "41"; src.entryRelationship as entry where ((typeCode = 'COMP') and (substanceAdministration.templateId.root = '2.16.756.5.30.1.1.10.4.52')) -> medicationStatement.dosage as dosage then DosageInstructionsNonStructuredEntryContentModule(section, entry, dosage) "52"; src.entryRelationship as entry where ((typeCode = 'COMP') and (sequenceNumber.value >= 0)) -> medicationStatement.dosage as dosage then DosageInstructionsEntryDosageChange(src, entry, dosage) "36"; src.entryRelationship as entry where ((typeCode = 'REFR') and substanceAdministration.templateId.where(root = '1.3.6.1.4.1.19376.1.9.1.3.10').exists()) -> medicationStatement.extension as ext then MTPReferenceEntryContentModule(entry, ext) "MTPReferenceEntry"; src.entryRelationship as entry where ((typeCode = 'COMP') and act.templateId.where(root = '2.16.756.5.30.1.1.10.4.2').exists()) then { entry.act as act -> medicationStatement.note as note then AnnotationComment(section, act, note) "annotation"; } "2"; src.entryRelationship as entry where ((typeCode = 'COMP') and act.templateId.where(root = '1.3.6.1.4.1.19376.1.9.1.3.9.1').exists()) then { entry.act as act -> medicationStatement as medicationStatement then SubstitutionStatement(act, medicationStatement) "substitution"; } "1"; } // source https://art-decor.org/art-decor/decor-templates--ch-pharm-?id=2.16.756.5.30.1.1.10.4.36 // target: http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-split // dosage for split dosing, with sequences group DosageInstructionsEntryDosageChange(source src : substanceAdministration, source entry : entryRelationship, target dosage : Dosage) { entry.sequenceNumber as sequenceNumber then { sequenceNumber.value as val -> dosage.sequence = val; }; src as src -> dosage as dosage then EffectiveTimeStartEnd(src, dosage) "effectiveTimeStartEnd"; entry.substanceAdministration as src -> dosage as dosage then EffectiveTimeWhen(src, dosage) "effectiveTimeWhen"; src.routeCode as routeCode -> dosage.route as route then CECodeableConcept(routeCode, route); entry.substanceAdministration as src -> dosage as dosage then DoseQuantity(src, dosage) "doseQuantity"; } // effective time start & end for dosage group EffectiveTimeStartEnd(source src : substanceAdministration, target dosage : Dosage) { src.effectiveTime : IVL_TS as effectiveTime -> dosage.timing as timing share sharetiming then { effectiveTime -> timing.repeat as repeat then { effectiveTime -> repeat.bounds = create('Period') as period then { effectiveTime.low as low then { low.value as lowDate -> period.start = lowDate "lowDate"; }; effectiveTime.high as high then { high.value as highDate -> period.end = highDate "highDate"; }; } "period"; } "repeat"; } "effectiveTime-IVL-TS"; } // effective time when for dosage group EffectiveTimeWhen(source src : substanceAdministration, target dosage : Dosage) { src.effectiveTime : EIVL_TS as effectiveTime -> dosage.timing as timing share sharetiming then { effectiveTime -> timing.repeat as repeat then { effectiveTime.event as event then { event.code as code -> repeat.when = code; }; } "repeat"; } "effectiveTime-EIVL-TS"; src.effectiveTime : SXPR_TS as effectiveTime -> dosage.timing as timing share sharetiming then { effectiveTime -> timing.repeat as repeat then { effectiveTime.comp as comp then { comp.event as event then { event.code as code -> repeat.when = code; }; }; } "repeat"; } "effectiveTime-SXPR-TS"; } // source: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.41 // target: reasonCode Coding (e.g. http://build.fhir.org/ig/hl7ch/ig/ch-emed/StructureDefinition/ch-emed-medicationstatement) group TreatmentReasonEntryContentModule(source section : Section, source observation : Observation, target reasonCode : Coding) { // extraxt text (Bluthochdruck) from id #mtpc.1.reason in section text <td ID="mtpc.1.reason">Bluthochdruck</td> observation.text as text then { text.data as data -> reasonCode.text = data "level3"; text.reference as reference then { reference.value as value -> reasonCode.extension as ext then NarrativeLink(value, ext) "narrativeLink"; }; }; } // source: https://art-decor.org/art-decor/decor-templates--ch-pharm-?section=templates&id=2.16.756.5.30.1.1.10.4.45 // target: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-ext-treatmentplan.html group MTPReferenceEntryContentModule(source entryrelationship, target ext : Extension) { entryrelationship -> ext.url = 'http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-ext-treatmentplan' "url"; entryrelationship.substanceAdministration as substanceAdministration then { substanceAdministration.id as id -> ext.extension as ext then InnerExtensionId(id, ext) "innerExtensionId"; substanceAdministration.reference as reference then { reference.externalDocument as externalDocument then { externalDocument.id as id -> ext.extension as ext then InnerExtensionExternalDocumentId(id, ext) "innerExtensionExternalDocumentId"; }; } "substanceAdministration"; } "id"; } // source: https://art-decor.org/art-decor/decor-templates--ch-pharm-?section=templates&id=2.16.756.5.30.1.1.10.4.52 // target: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-dosage-nonstructured.html group DosageInstructionsNonStructuredEntryContentModule(source section : Section, source entry : Element, target dosage : Dosage) { // see MedicationTreatmentPlanItemEntryContentModule entry.substanceAdministration as observation then { observation.text as text then { text.data as data -> dosage.text = data "level3"; text.reference as reference then { reference.value as value -> dosage.extension as ext then NarrativeLink(value, ext) "narrativeLink"; }; }; } "observation"; } // source: Substitution act Contains 1.3.6.1.4.1.19376.1.9.1.3.9.2 IHE Substitution Act Content Module // target: http://build.fhir.org/ig/hl7ch/ch-emed/StructureDefinition-ch-emed-medicationdispense.html group SubstitutionDispense(source act : Act, target medicationDispense : MedicationDispense) { act -> medicationDispense.substitution as substitution then { act -> substitution.wasSubstituted as wasSubstituted, wasSubstituted.value = 'true' "wasSubstituted"; // act.code as code -> substitution.type as type then CECodeableConcept(code, type) "type"; act.code as actCode -> substitution.type as type, type.coding as coding then { actCode -> coding.system as systemCC, systemCC.value = 'http://terminology.hl7.org/CodeSystem/v3-substanceAdminSubstitution' "system"; actCode.code as code -> coding.code as codeCC, codeCC.value = code; actCode.displayName as display -> coding.display as displayCC, displayCC.value = display "display"; } "allowedCC"; } "substitution"; } // source: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.42 // target: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationdispense.html group DispenseItemEntryContentModule(source section : Section, source src : Supply, source patient : Patient, target medicationDispense : MedicationDispense) { // src.templateId as template then TemplateID(template, medicationDispense) "templateId"; src.id -> medicationDispense.identifier; patient -> medicationDispense.subject = create('Reference') as reference, reference.reference = ('urn:uuid:' + %patient.id) "patient"; src -> medicationDispense.status = 'completed' "completed"; src.text as text then { text.reference as reference then { reference.value as value -> medicationDispense.extension as ext then NarrativeLink(value, ext) "narrativeLink"; }; }; src -> medicationDispense.contained = create('Medication') as medication then ManufacturedMaterialEntryContentModuleDispense(src, medicationDispense, medication) "medication"; src.entryRelationship as entry where ((typeCode = 'COMP') and (substanceAdministration.templateId.root = '2.16.756.5.30.1.1.10.4.52')) -> medicationDispense.dosageInstruction as dosage then DosageInstructionsNonStructuredEntryContentModule(section, entry, dosage) "52"; src.entryRelationship as entryRelationship then { entryRelationship.substanceAdministration as substanceAdministration then { // dosage for split dosing, as sequences are present there substanceAdministration.entryRelationship as entryRelationship where ((typeCode = 'COMP') and (sequenceNumber.value >= 0)) -> medicationDispense.dosageInstruction as dosage then DosageInstructionsEntryDosageChange(substanceAdministration, entryRelationship, dosage) "36"; }; }; src.entryRelationship as entry where ((typeCode = 'REFR') and substanceAdministration.templateId.where(root = '1.3.6.1.4.1.19376.1.9.1.3.10').exists()) -> medicationDispense.extension as ext then MTPReferenceEntryContentModule(entry, ext) "MTPReferenceEntry"; src.entryRelationship as entry where ((typeCode = 'COMP') and act.templateId.where(root = '2.16.756.5.30.1.1.10.4.2').exists()) then { entry.act as act -> medicationDispense.note as note then AnnotationComment(section, act, note) "annotation"; } "2"; src.entryRelationship as entry where ((typeCode = 'COMP') and act.templateId.where(root = '1.3.6.1.4.1.19376.1.9.1.3.9.2').exists()) then { entry.act as act -> medicationDispense as medicationDispense then SubstitutionDispense(act, medicationDispense) "substitution"; } "2"; } // dose quantity for dosage (application schema) group DoseQuantity(source src : substanceAdministration, target dosage : Dosage) { src.doseQuantity as doseQuantity -> dosage.doseAndRate as doseAndRate then { doseQuantity.value as value -> doseAndRate.dose = create('Quantity') as quantity then { value -> quantity.value = value "value"; doseQuantity.unit as unit -> quantity.code = unit; doseQuantity.unit as unit -> quantity.system = ('http://fhir.ch/ig/ch-emed/ValueSet/UnitCode'.resolve().compose.include.where(concept.where(code = %unit)).system); doseQuantity.unit as unit -> quantity.unit = ('http://fhir.ch/ig/ch-emed/ValueSet/UnitCode'.resolve().compose.include.concept.where(code = %unit).display); } "quantity"; }; } // source: Substitution permission Contains 1.3.6.1.4.1.19376.1.9.1.3.9.1 IHE Substitution Permission Content Module (DYNAMIC) // target: http://build.fhir.org/ig/hl7ch/ch-emed/StructureDefinition-ch-emed-medicationrequest.html group SubstitutionRequest(source act : Act, target medicationRequest : MedicationRequest) { act -> medicationRequest.substitution as substitution then { // act.code as code -> substitution.allowed = create('CodeableConcept') as allowedCC then CECodeableConcept(code, allowedCC) "allowedCC"; act.code as actCode -> substitution.allowed = create('CodeableConcept') as allowedCC, allowedCC.coding as coding then { actCode -> coding.system as systemCC, systemCC.value = 'http://terminology.hl7.org/CodeSystem/v3-substanceAdminSubstitution' "system"; actCode.code as code -> coding.code as codeCC, codeCC.value = code; actCode.displayName as display -> coding.display as displayCC, displayCC.value = display "display"; } "allowedCC"; } "substitutionRequest"; } // source: Substitution permission Contains 1.3.6.1.4.1.19376.1.9.1.3.9.1 IHE Substitution Permission Content Module (DYNAMIC) // target: http://build.fhir.org/ig/hl7ch/ch-emed/StructureDefinition-ch-emed-medicationstatement.html group SubstitutionStatement(source act : Act, target medicationStatement : MedicationStatement) { act -> medicationStatement.extension as ext then { act -> ext.url = 'http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-ext-substitution' then { // act.code as code -> ext.value = create('CodeableConcept') as valueCC then CECodeableConcept(code, valueCC) "valueCC"; act.code as actCode -> ext.value = create('CodeableConcept') as valueCC, valueCC.coding as coding then { actCode -> coding.system as systemCC, systemCC.value = 'http://terminology.hl7.org/CodeSystem/v3-substanceAdminSubstitution' "system"; actCode.code as code -> coding.code as codeCC, codeCC.value = code; actCode.displayName as display -> coding.display as displayCC, displayCC.value = display "display"; } "valueCC"; } "substitutionExtension"; } "substitutionStatement"; } // Number of packages // source: https://art-decor.org/art-decor/decor-templates--cdachemed-?id=2.16.756.5.30.1.1.10.4.38 // target: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationrequest.html group PrescribedQuantity(source supply : Supply, target medicationRequest : MedicationRequest) { supply.quantity as quantity -> medicationRequest.dispenseRequest as dispenseRequest, dispenseRequest.quantity as quant then { // IHE-PRE: If the product-element contains package information, the unit attribute is not be present quantity.value as value -> quant.value = value; // IHE-PRE: If the product-element does not contain package information, the unit attribut is present and the value SHALL be out of the UCUM code system quantity.unit as unit then { unit -> quant.unit = unit "unit"; unit -> quant.system = 'http://unitsofmeasure.org' "ucum"; unit -> quant.code = unit "code"; }; }; } // source: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.33 // target: http://build.fhir.org/ig/hl7ch/ch-emed/StructureDefinition-ch-emed-medicationrequest.html group ManufacturedMaterialEntryContentModuleRequest(source src : SubstanceAdministration, target medicationRequest : MedicationRequest, target medication : Medication) { src -> medication.id = 'med', medicationRequest.medication = create('Reference') as vt, vt.reference = '#med' "medication"; src.consumable as consumable then { consumable.manufacturedProduct as manufacturedProduct then { manufacturedProduct.manufacturedMaterial as manufacturedMaterial then { manufacturedMaterial.name as name where asContent.exists() = false -> medication.code as fhircode, fhircode.text = (%manufacturedMaterial.name.other) "code"; manufacturedMaterial.asContent as asContent then { asContent.containerPackagedMedicine as containerPackagedMedicine then { containerPackagedMedicine.code as code -> medication.code as fhircode share medcode then CECodeableConcept(code, fhircode); containerPackagedMedicine.name as name -> medication.code as fhircode share medcode then { name -> fhircode.text = (%name.other) "text"; } "text"; containerPackagedMedicine.formCode as formCode -> medication.form as form then CECodeableConcept(formCode, form); // Package size containerPackagedMedicine.capacityQuantity as capacityQuantity -> medication.amount = create('Ratio') as ratio, ratio.denominator = create('Quantity') as denominator, denominator.value = '1', denominator.unit = 'Package', denominator.system = 'http://unitsofmeasure.org', denominator.code = '{Package}', ratio.numerator = create('Quantity') as quantity then EmedPQQuantity(capacityQuantity, quantity); }; }; manufacturedMaterial.ingredient as ingredient -> medication.ingredient as ing then { ingredient.quantity as quantity -> ing.strength = create('Ratio') as strength then EmedRTOPQPQRatio(quantity, strength) "strength"; ingredient.ingredient as medingredient then { medingredient.code as code -> ing.item = create('CodeableConcept') as ingcode, ingcode.text = (%medingredient.name.other) then CECodeableConcept(code, ingcode) "ingredientCode"; }; }; }; }; // dosage for normal dosing, as no sequences are present there src where $this.entryRelationship.sequenceNumber.exists() = false -> medicationRequest.dosageInstruction as dosage then DosageInstructionsStartStopFrequency(src, dosage) "dosage"; }; } // source: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.43 // target: http://build.fhir.org/ig/hl7ch/ch-emed/StructureDefinition-ch-emed-medicationrequest.html group PrescriptionItemEntryContentModule(source section : Section, source src : SubstanceAdministration, source patient : Patient, target medicationRequest : MedicationRequest) { src.id -> medicationRequest.identifier; patient -> medicationRequest.subject = create('Reference') as reference, reference.reference = ('urn:uuid:' + %patient.id) "patient"; src -> medicationRequest.status = 'completed' "completed"; src -> medicationRequest.intent = 'order' "order"; src.text as text then { text.reference as reference then { reference.value as value -> medicationRequest.extension as ext then NarrativeLink(value, ext) "narrativeLink"; }; }; src -> medicationRequest.contained = create('Medication') as medication then ManufacturedMaterialEntryContentModuleRequest(src, medicationRequest, medication) "medication"; src.entryRelationship as entry where typeCode = 'RSON' then { entry.observation as observation -> medicationRequest.reasonCode as reasonCode then TreatmentReasonEntryContentModule(section, observation, reasonCode) "reasonCode"; } "41"; src.entryRelationship as entry where ((typeCode = 'COMP') and (substanceAdministration.templateId.root = '2.16.756.5.30.1.1.10.4.52')) -> medicationRequest.dosageInstruction as dosage then DosageInstructionsNonStructuredEntryContentModule(section, entry, dosage) "52"; // dosage for split dosing, as sequences are present there src.entryRelationship as entry where ((typeCode = 'COMP') and (sequenceNumber.value >= 0)) -> medicationRequest.dosageInstruction as dosage then DosageInstructionsEntryDosageChange(src, entry, dosage) "36"; src.entryRelationship as entry where ((typeCode = 'REFR') and substanceAdministration.templateId.where(root = '1.3.6.1.4.1.19376.1.9.1.3.10').exists()) -> medicationRequest.extension as ext then MTPReferenceEntryContentModule(entry, ext) "MTPReferenceEntry"; src.entryRelationship as entry where ((typeCode = 'COMP') and act.templateId.where(root = '2.16.756.5.30.1.1.10.4.2').exists()) then { entry.act as act -> medicationRequest.note as note then AnnotationComment(section, act, note) "annotation"; } "2"; src.repeatNumber as repeatNumber -> medicationRequest.dispenseRequest as dispenseRequest then { repeatNumber.value as val -> dispenseRequest.numberOfRepeatsAllowed = val "repeatNumber"; } "repeats"; src.entryRelationship as entry where ((typeCode = 'COMP') and supply.templateId.where(root = '1.3.6.1.4.1.19376.1.9.1.3.8').exists()) then { entry.supply as supply -> medicationRequest as medicationRequest then PrescribedQuantity(supply, medicationRequest) "quantity"; } "8"; src.entryRelationship as entry where ((typeCode = 'COMP') and act.templateId.where(root = '1.3.6.1.4.1.19376.1.9.1.3.9.1').exists()) then { entry.act as act -> medicationRequest as medicationRequest then SubstitutionRequest(act, medicationRequest) "substitution"; } "1"; } // source: https://art-decor.org/art-decor/decor-templates--ch-pharm-?id=2.16.756.5.30.1.1.10.4.35 // target: http://build.fhir.org/ig/hl7ch/ch-emed/StructureDefinition/ch-emed-dosage-structured-normal // dosage for normal dosing, without sequences group DosageInstructionsStartStopFrequency(source src : SubstanceAdministration, target dosage : Dosage) { src as src -> dosage as dosage then EffectiveTimeStartEnd(src, dosage) "effectiveTimeStartEnd"; src as src -> dosage as dosage then EffectiveTimeWhen(src, dosage) "effectiveTimeWhen"; src.routeCode as routeCode -> dosage.route as route then CECodeableConcept(routeCode, route); src as src -> dosage as dosage then DoseQuantity(src, dosage) "doseQuantity"; } // source: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.44 // target: http://build.fhir.org/ig/hl7ch/ch-emed/StructureDefinition-ch-emed-observation.html group PharmaceuticalAdviceItemEntryContentModule(source section : Section, source src : Observation, source patient : Patient, target observation : Observation, target bundle : Bundle) { src.id -> observation.identifier; patient -> observation.subject = create('Reference') as reference, reference.reference = ('urn:uuid:' + %patient.id) "patient"; src -> observation.status = 'final' "final"; src.effectiveTime as effectiveTime -> observation.effective = create('dateTime') as value then TSDateTime(effectiveTime, value) "value"; src.entryRelationship as entry where ((typeCode = 'REFR') and substanceAdministration.templateId.where(root = '1.3.6.1.4.1.19376.1.9.1.3.10').exists()) -> observation.extension as ext then MTPReferenceEntryContentModule(entry, ext) "MTPReferenceEntry"; src.entryRelationship as entry where ((typeCode = 'REFR') and substanceAdministration.templateId.where(root = '1.3.6.1.4.1.19376.1.9.1.3.7').exists()) -> bundle.entry as e, e.id = uuid() as uuid, e.fullUrl = append('urn:uuid:', uuid), e.resource = create('MedicationStatement') as medicationstatement, observation.extension as ext, ext.url = 'http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-ext-medicationstatement-changed', ext.value = create('Reference') as reference, reference.reference = append('urn:uuid:', uuid) then { entry.substanceAdministration as substanceAdministration then MedicationTreatmentPlanItemEntryContentModule(section, substanceAdministration, patient, medicationstatement); } "cdaEntry"; src.text as text -> observation.note as note then { text.data as data -> note.text = data "level3observation"; text where (data.exists() = false) -> note.text = (%section.text.substring(%section.text.indexOf(%src.text.reference.value.substring(1))).substring(%section.text.substring(%section.text.indexOf(%src.text.reference.value.substring(1))).indexOf('>') + 1, %section.text.substring(%section.text.indexOf(%src.text.reference.value.substring(1))).indexOf('<') - %section.text.substring(%section.text.indexOf(%src.text.reference.value.substring(1))).indexOf('>') - 1)) "idRef"; text.reference as reference then { reference.value as value -> note.extension as ext then NarrativeLink(value, ext) "narrativeLink"; }; } "note"; src.code -> observation.code; } // _________________________ Template Type not specified _________________________ // target: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-ext-treatmentplan.html group InnerExtensionExternalDocumentId(source src, target ext : Extension) { src -> ext.url = 'externalDocumentId' "url"; src -> ext.value = create('Identifier') as id then II(src, id) "value"; } // target: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-ext-treatmentplan.html group InnerExtensionId(source src, target ext : Extension) { src -> ext.url = 'id' "url"; src -> ext.value = create('Identifier') as id then II(src, id) "value"; }
{
"resourceType" : "StructureMap",
"id" : "CdaChEmedToBundle",
"text" : {
"status" : "generated",
"div" : "<div xmlns=\"http://www.w3.org/1999/xhtml\">\n <pre>map "http://fhir.ch/ig/cda-fhir-maps/StructureMap/CdaChEmedToBundle" = "CdaChEmedToBundle"\n\n// Medication Entries\n// 2020-10-30 Oliver Egger, copyright ahdis ag, Apache License\n// CDA-CH-EMED: https://art-decor.org/art-decor/decor-project--cdachemed-\n// FHIR CH-EMED: http://fhir.ch/ig/ch-emed/index.html\n\nuses "http://hl7.org/fhir/cda/StructureDefinition/ClinicalDocument" alias ClinicalDocument as source\nuses "http://hl7.org/fhir/cda/StructureDefinition/AssignedAuthor" alias AssignedAuthor as source\nuses "http://hl7.org/fhir/cda/StructureDefinition/AssignedEntity" alias AssignedEntity as source\nuses "http://hl7.org/fhir/cda/StructureDefinition/Author" alias Author as source\nuses "http://hl7.org/fhir/cda/StructureDefinition/CustodianOrganization" alias CustodianOrganization as source\nuses "http://hl7.org/fhir/cda/StructureDefinition/IVL_TS" alias IVL_TS as source\nuses "http://hl7.org/fhir/cda/StructureDefinition/EIVL_TS" alias EIVL_TS as source\nuses "http://hl7.org/fhir/cda/StructureDefinition/Observation" alias Observation as source\nuses "http://hl7.org/fhir/cda/StructureDefinition/PatientRole" alias PatientRole as source\nuses "http://hl7.org/fhir/cda/StructureDefinition/RecordTarget" alias RecordTarget as source\nuses "http://hl7.org/fhir/cda/StructureDefinition/Section" alias Section as source\nuses "http://hl7.org/fhir/cda/StructureDefinition/SubstanceAdministration" alias SubstanceAdministration as source\nuses "http://hl7.org/fhir/cda/StructureDefinition/SXPR_TS" alias SXPR_TS as source\nuses "http://hl7.org/fhir/StructureDefinition/Bundle" alias Bundle as target\nuses "http://hl7.org/fhir/StructureDefinition/Composition" alias Composition as produced\nuses "http://hl7.org/fhir/StructureDefinition/Patient" alias Patient as produced\nuses "http://hl7.org/fhir/StructureDefinition/Practitioner" alias Practitioner as produced\nuses "http://hl7.org/fhir/StructureDefinition/Organization" alias Organization as produced\nuses "http://hl7.org/fhir/StructureDefinition/MedicationStatement" alias MedicationStatement as produced\nuses "http://hl7.org/fhir/StructureDefinition/Dosage" alias Dosage as produced\nuses "http://hl7.org/fhir/StructureDefinition/Observation" alias Observation as produced\n\nimports "http://fhir.ch/ig/cda-fhir-maps/StructureMap/CdaToFhirTypes"\nimports "http://fhir.ch/ig/cda-fhir-maps/StructureMap/CdaToBundle"\nimports "http://fhir.ch/ig/cda-fhir-maps/StructureMap/CdaChToBundle"\n\n// source: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.2\n// target: Annotation note (e.g. http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationstatement.html)\ngroup AnnotationComment(source section : Section, source act : Act, target note : Annotation) {\n act.text as text then {\n text.data as data -> note.text = data "level3";\n text.reference as reference then {\n reference.value as value -> note.extension as ext then NarrativeLink(value, ext) "narrativeLink";\n };\n };\n}\n\n// source: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.33\n// target: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationdispense.html\ngroup ManufacturedMaterialEntryContentModuleDispense(source src : Supply, target medicationDispense : MedicationDispense, target medication : Medication) {\n src -> medication.id = 'med', medicationDispense.medication = create('Reference') as vt, vt.reference = '#med' "medication";\n // quantity value (number of packages)\n src.quantity as quantity -> medicationDispense.quantity as medDispQuantity then {\n // IHE-DIS: If the product-element contains package information, the unit attribute is not be present\n quantity.value as value -> medDispQuantity.value = value;\n // IHE-DIS: If the product-element does not contain package information, the unit attribut is present and the value SHALL be out of the UCUM code system\n quantity.unit as unit then {\n unit -> medDispQuantity.unit = unit "unit";\n unit -> medDispQuantity.system = 'http://unitsofmeasure.org' "ucum";\n unit -> medDispQuantity.code = unit "code";\n };\n };\n src.product as product then {\n product.manufacturedProduct as manufacturedProduct then {\n manufacturedProduct.manufacturedMaterial as manufacturedMaterial then {\n manufacturedMaterial.name as name where asContent.exists() = false -> medication.code as fhircode, fhircode.text = (%manufacturedMaterial.name.other) "code";\n manufacturedMaterial.asContent as asContent then {\n asContent.containerPackagedMedicine as containerPackagedMedicine then {\n containerPackagedMedicine.code as code -> medication.code as fhircode share medcode then CECodeableConcept(code, fhircode);\n containerPackagedMedicine.name as name -> medication.code as fhircode share medcode then {\n name -> fhircode.text = (%name.other) "text";\n } "text";\n containerPackagedMedicine.formCode as formCode -> medication.form as form then CECodeableConcept(formCode, form);\n // Package size\n containerPackagedMedicine.capacityQuantity as capacityQuantity -> medication.amount = create('Ratio') as ratio, ratio.denominator = create('Quantity') as denominator, denominator.value = '1', denominator.unit = 'Package', denominator.system = 'http://unitsofmeasure.org', denominator.code = '{Package}', ratio.numerator = create('Quantity') as quantity then EmedPQQuantity(capacityQuantity, quantity);\n };\n };\n manufacturedMaterial.ingredient as ingredient -> medication.ingredient as ing then {\n ingredient.quantity as quantity -> ing.strength = create('Ratio') as strength then EmedRTOPQPQRatio(quantity, strength) "strength";\n ingredient.ingredient as medingredient then {\n medingredient.code as code -> ing.item = create('CodeableConcept') as ingcode, ingcode.text = (%medingredient.name.other) then CECodeableConcept(code, ingcode) "ingredientCode";\n };\n };\n };\n };\n // dosage for normal dosing, as no sequences are present there\n src.entryRelationship as entry then {\n entry.substanceAdministration as substanceAdministration then {\n substanceAdministration where $this.entryRelationship.sequenceNumber.exists() = false -> medicationDispense.dosageInstruction as dosage then DosageInstructionsStartStopFrequency(substanceAdministration, dosage) "dosage";\n };\n } "entry";\n };\n}\n\ngroup EmedPQQuantity(source src : PQ, target tgt : Quantity) {\n src.value as value -> tgt.value = value;\n src.unit as unit -> tgt.code = unit;\n src.unit as unit -> tgt.system = ('http://fhir.ch/ig/ch-emed/ValueSet/UnitCode'.resolve().compose.include.where(concept.where(code = %unit)).system);\n src.unit as unit -> tgt.unit = ('http://fhir.ch/ig/ch-emed/ValueSet/UnitCode'.resolve().compose.include.concept.where(code = %unit).display);\n}\n\ngroup EmedRTOPQPQRatio(source src : RTO_PQ_PQ, target tgt : Ratio) {\n src.numerator as numerator -> tgt.numerator as targetNumerator then EmedPQQuantity(numerator, targetNumerator);\n src.denominator as denominator -> tgt.denominator as targetDenominator then EmedPQQuantity(denominator, targetDenominator);\n}\n\n// source: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.33\n// target: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationstatement.html\ngroup ManufacturedMaterialEntryContentModuleStatement(source src : SubstanceAdministration, target medicationStatement : MedicationStatement, target medication : Medication) {\n src -> medication.id = 'med', medicationStatement.medication = create('Reference') as vt, vt.reference = '#med' "medication";\n src.consumable as consumable then {\n consumable.manufacturedProduct as manufacturedProduct then {\n manufacturedProduct.manufacturedMaterial as manufacturedMaterial then {\n manufacturedMaterial.name as name where asContent.exists() = false -> medication.code as fhircode, fhircode.text = (%manufacturedMaterial.name.other) "code";\n manufacturedMaterial.asContent as asContent then {\n asContent.containerPackagedMedicine as containerPackagedMedicine then {\n containerPackagedMedicine.code as code -> medication.code as fhircode share medcode then CECodeableConcept(code, fhircode);\n containerPackagedMedicine.name as name -> medication.code as fhircode share medcode then {\n name -> fhircode.text = (%name.other) "text";\n } "text";\n containerPackagedMedicine.formCode as formCode -> medication.form as form then CECodeableConcept(formCode, form);\n // Package size\n containerPackagedMedicine.capacityQuantity as capacityQuantity -> medication.amount = create('Ratio') as ratio, ratio.denominator = create('Quantity') as denominator, denominator.value = '1', denominator.unit = 'Package', denominator.system = 'http://unitsofmeasure.org', denominator.code = '{Package}', ratio.numerator = create('Quantity') as quantity then EmedPQQuantity(capacityQuantity, quantity);\n };\n };\n manufacturedMaterial.ingredient as ingredient -> medication.ingredient as ing then {\n ingredient.quantity as quantity -> ing.strength = create('Ratio') as strength then EmedRTOPQPQRatio(quantity, strength) "strength";\n ingredient.ingredient as medingredient then {\n medingredient.code as code -> ing.item = create('CodeableConcept') as ingcode, ingcode.text = (%medingredient.name.other) then CECodeableConcept(code, ingcode) "ingredientCode";\n };\n };\n };\n };\n // dosage for normal dosing, as no sequences are present there\n src where $this.entryRelationship.sequenceNumber.exists() = false -> medicationStatement.dosage as dosage then DosageInstructionsStartStopFrequency(src, dosage) "dosage";\n };\n}\n\n// source: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.34\n// target: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationstatement.html\ngroup MedicationTreatmentPlanItemEntryContentModule(source section : Section, source src : SubstanceAdministration, source patient : Patient, target medicationStatement : MedicationStatement) {\n // src.templateId as template then TemplateID(template, medicationStatement) "templateId";\n src.id -> medicationStatement.identifier;\n patient -> medicationStatement.subject = create('Reference') as reference, reference.reference = ('urn:uuid:' + %patient.id) "patient";\n src -> medicationStatement.status = 'completed' "completed";\n src.text as text then {\n text.reference as reference then {\n reference.value as value -> medicationStatement.extension as ext then NarrativeLink(value, ext) "narrativeLink";\n };\n };\n src -> medicationStatement.contained = create('Medication') as medication then ManufacturedMaterialEntryContentModuleStatement(src, medicationStatement, medication) "medication";\n src.entryRelationship as entry where typeCode = 'RSON' then {\n entry.observation as observation -> medicationStatement.reasonCode as reasonCode then TreatmentReasonEntryContentModule(section, observation, reasonCode) "reasonCode";\n } "41";\n src.entryRelationship as entry where ((typeCode = 'COMP') and (substanceAdministration.templateId.root = '2.16.756.5.30.1.1.10.4.52')) -> medicationStatement.dosage as dosage then DosageInstructionsNonStructuredEntryContentModule(section, entry, dosage) "52";\n src.entryRelationship as entry where ((typeCode = 'COMP') and (sequenceNumber.value >= 0)) -> medicationStatement.dosage as dosage then DosageInstructionsEntryDosageChange(src, entry, dosage) "36";\n src.entryRelationship as entry where ((typeCode = 'REFR') and substanceAdministration.templateId.where(root = '1.3.6.1.4.1.19376.1.9.1.3.10').exists()) -> medicationStatement.extension as ext then MTPReferenceEntryContentModule(entry, ext) "MTPReferenceEntry";\n src.entryRelationship as entry where ((typeCode = 'COMP') and act.templateId.where(root = '2.16.756.5.30.1.1.10.4.2').exists()) then {\n entry.act as act -> medicationStatement.note as note then AnnotationComment(section, act, note) "annotation";\n } "2";\n src.entryRelationship as entry where ((typeCode = 'COMP') and act.templateId.where(root = '1.3.6.1.4.1.19376.1.9.1.3.9.1').exists()) then {\n entry.act as act -> medicationStatement as medicationStatement then SubstitutionStatement(act, medicationStatement) "substitution";\n } "1";\n}\n\n// source https://art-decor.org/art-decor/decor-templates--ch-pharm-?id=2.16.756.5.30.1.1.10.4.36\n// target: http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-split\n// dosage for split dosing, with sequences\ngroup DosageInstructionsEntryDosageChange(source src : substanceAdministration, source entry : entryRelationship, target dosage : Dosage) {\n entry.sequenceNumber as sequenceNumber then {\n sequenceNumber.value as val -> dosage.sequence = val;\n };\n src as src -> dosage as dosage then EffectiveTimeStartEnd(src, dosage) "effectiveTimeStartEnd";\n entry.substanceAdministration as src -> dosage as dosage then EffectiveTimeWhen(src, dosage) "effectiveTimeWhen";\n src.routeCode as routeCode -> dosage.route as route then CECodeableConcept(routeCode, route);\n entry.substanceAdministration as src -> dosage as dosage then DoseQuantity(src, dosage) "doseQuantity";\n}\n\n// effective time start & end for dosage\ngroup EffectiveTimeStartEnd(source src : substanceAdministration, target dosage : Dosage) {\n src.effectiveTime : IVL_TS as effectiveTime -> dosage.timing as timing share sharetiming then {\n effectiveTime -> timing.repeat as repeat then {\n effectiveTime -> repeat.bounds = create('Period') as period then {\n effectiveTime.low as low then {\n low.value as lowDate -> period.start = lowDate "lowDate";\n };\n effectiveTime.high as high then {\n high.value as highDate -> period.end = highDate "highDate";\n };\n } "period";\n } "repeat";\n } "effectiveTime-IVL-TS";\n}\n\n// effective time when for dosage\ngroup EffectiveTimeWhen(source src : substanceAdministration, target dosage : Dosage) {\n src.effectiveTime : EIVL_TS as effectiveTime -> dosage.timing as timing share sharetiming then {\n effectiveTime -> timing.repeat as repeat then {\n effectiveTime.event as event then {\n event.code as code -> repeat.when = code;\n };\n } "repeat";\n } "effectiveTime-EIVL-TS";\n src.effectiveTime : SXPR_TS as effectiveTime -> dosage.timing as timing share sharetiming then {\n effectiveTime -> timing.repeat as repeat then {\n effectiveTime.comp as comp then {\n comp.event as event then {\n event.code as code -> repeat.when = code;\n };\n };\n } "repeat";\n } "effectiveTime-SXPR-TS";\n}\n\n// source: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.41\n// target: reasonCode Coding (e.g. http://build.fhir.org/ig/hl7ch/ig/ch-emed/StructureDefinition/ch-emed-medicationstatement)\ngroup TreatmentReasonEntryContentModule(source section : Section, source observation : Observation, target reasonCode : Coding) {\n // extraxt text (Bluthochdruck) from id #mtpc.1.reason in section text <td ID="mtpc.1.reason">Bluthochdruck</td>\n observation.text as text then {\n text.data as data -> reasonCode.text = data "level3";\n text.reference as reference then {\n reference.value as value -> reasonCode.extension as ext then NarrativeLink(value, ext) "narrativeLink";\n };\n };\n}\n\n// source: https://art-decor.org/art-decor/decor-templates--ch-pharm-?section=templates&id=2.16.756.5.30.1.1.10.4.45\n// target: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-ext-treatmentplan.html\ngroup MTPReferenceEntryContentModule(source entryrelationship, target ext : Extension) {\n entryrelationship -> ext.url = 'http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-ext-treatmentplan' "url";\n entryrelationship.substanceAdministration as substanceAdministration then {\n substanceAdministration.id as id -> ext.extension as ext then InnerExtensionId(id, ext) "innerExtensionId";\n substanceAdministration.reference as reference then {\n reference.externalDocument as externalDocument then {\n externalDocument.id as id -> ext.extension as ext then InnerExtensionExternalDocumentId(id, ext) "innerExtensionExternalDocumentId";\n };\n } "substanceAdministration";\n } "id";\n}\n\n// source: https://art-decor.org/art-decor/decor-templates--ch-pharm-?section=templates&id=2.16.756.5.30.1.1.10.4.52\n// target: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-dosage-nonstructured.html\ngroup DosageInstructionsNonStructuredEntryContentModule(source section : Section, source entry : Element, target dosage : Dosage) {\n // see MedicationTreatmentPlanItemEntryContentModule\n entry.substanceAdministration as observation then {\n observation.text as text then {\n text.data as data -> dosage.text = data "level3";\n text.reference as reference then {\n reference.value as value -> dosage.extension as ext then NarrativeLink(value, ext) "narrativeLink";\n };\n };\n } "observation";\n}\n\n// source: Substitution act Contains 1.3.6.1.4.1.19376.1.9.1.3.9.2 IHE Substitution Act Content Module\n// target: http://build.fhir.org/ig/hl7ch/ch-emed/StructureDefinition-ch-emed-medicationdispense.html\ngroup SubstitutionDispense(source act : Act, target medicationDispense : MedicationDispense) {\n act -> medicationDispense.substitution as substitution then {\n act -> substitution.wasSubstituted as wasSubstituted, wasSubstituted.value = 'true' "wasSubstituted";\n // act.code as code -> substitution.type as type then CECodeableConcept(code, type) "type";\n act.code as actCode -> substitution.type as type, type.coding as coding then {\n actCode -> coding.system as systemCC, systemCC.value = 'http://terminology.hl7.org/CodeSystem/v3-substanceAdminSubstitution' "system";\n actCode.code as code -> coding.code as codeCC, codeCC.value = code;\n actCode.displayName as display -> coding.display as displayCC, displayCC.value = display "display";\n } "allowedCC";\n } "substitution";\n}\n\n// source: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.42\n// target: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationdispense.html\ngroup DispenseItemEntryContentModule(source section : Section, source src : Supply, source patient : Patient, target medicationDispense : MedicationDispense) {\n // src.templateId as template then TemplateID(template, medicationDispense) "templateId";\n src.id -> medicationDispense.identifier;\n patient -> medicationDispense.subject = create('Reference') as reference, reference.reference = ('urn:uuid:' + %patient.id) "patient";\n src -> medicationDispense.status = 'completed' "completed";\n src.text as text then {\n text.reference as reference then {\n reference.value as value -> medicationDispense.extension as ext then NarrativeLink(value, ext) "narrativeLink";\n };\n };\n src -> medicationDispense.contained = create('Medication') as medication then ManufacturedMaterialEntryContentModuleDispense(src, medicationDispense, medication) "medication";\n src.entryRelationship as entry where ((typeCode = 'COMP') and (substanceAdministration.templateId.root = '2.16.756.5.30.1.1.10.4.52')) -> medicationDispense.dosageInstruction as dosage then DosageInstructionsNonStructuredEntryContentModule(section, entry, dosage) "52";\n src.entryRelationship as entryRelationship then {\n entryRelationship.substanceAdministration as substanceAdministration then {\n // dosage for split dosing, as sequences are present there\n substanceAdministration.entryRelationship as entryRelationship where ((typeCode = 'COMP') and (sequenceNumber.value >= 0)) -> medicationDispense.dosageInstruction as dosage then DosageInstructionsEntryDosageChange(substanceAdministration, entryRelationship, dosage) "36";\n };\n };\n src.entryRelationship as entry where ((typeCode = 'REFR') and substanceAdministration.templateId.where(root = '1.3.6.1.4.1.19376.1.9.1.3.10').exists()) -> medicationDispense.extension as ext then MTPReferenceEntryContentModule(entry, ext) "MTPReferenceEntry";\n src.entryRelationship as entry where ((typeCode = 'COMP') and act.templateId.where(root = '2.16.756.5.30.1.1.10.4.2').exists()) then {\n entry.act as act -> medicationDispense.note as note then AnnotationComment(section, act, note) "annotation";\n } "2";\n src.entryRelationship as entry where ((typeCode = 'COMP') and act.templateId.where(root = '1.3.6.1.4.1.19376.1.9.1.3.9.2').exists()) then {\n entry.act as act -> medicationDispense as medicationDispense then SubstitutionDispense(act, medicationDispense) "substitution";\n } "2";\n}\n\n// dose quantity for dosage (application schema)\ngroup DoseQuantity(source src : substanceAdministration, target dosage : Dosage) {\n src.doseQuantity as doseQuantity -> dosage.doseAndRate as doseAndRate then {\n doseQuantity.value as value -> doseAndRate.dose = create('Quantity') as quantity then {\n value -> quantity.value = value "value";\n doseQuantity.unit as unit -> quantity.code = unit;\n doseQuantity.unit as unit -> quantity.system = ('http://fhir.ch/ig/ch-emed/ValueSet/UnitCode'.resolve().compose.include.where(concept.where(code = %unit)).system);\n doseQuantity.unit as unit -> quantity.unit = ('http://fhir.ch/ig/ch-emed/ValueSet/UnitCode'.resolve().compose.include.concept.where(code = %unit).display);\n } "quantity";\n };\n}\n\n// source: Substitution permission Contains 1.3.6.1.4.1.19376.1.9.1.3.9.1 IHE Substitution Permission Content Module (DYNAMIC)\n// target: http://build.fhir.org/ig/hl7ch/ch-emed/StructureDefinition-ch-emed-medicationrequest.html\ngroup SubstitutionRequest(source act : Act, target medicationRequest : MedicationRequest) {\n act -> medicationRequest.substitution as substitution then {\n // act.code as code -> substitution.allowed = create('CodeableConcept') as allowedCC then CECodeableConcept(code, allowedCC) "allowedCC";\n act.code as actCode -> substitution.allowed = create('CodeableConcept') as allowedCC, allowedCC.coding as coding then {\n actCode -> coding.system as systemCC, systemCC.value = 'http://terminology.hl7.org/CodeSystem/v3-substanceAdminSubstitution' "system";\n actCode.code as code -> coding.code as codeCC, codeCC.value = code;\n actCode.displayName as display -> coding.display as displayCC, displayCC.value = display "display";\n } "allowedCC";\n } "substitutionRequest";\n}\n\n// source: Substitution permission Contains 1.3.6.1.4.1.19376.1.9.1.3.9.1 IHE Substitution Permission Content Module (DYNAMIC)\n// target: http://build.fhir.org/ig/hl7ch/ch-emed/StructureDefinition-ch-emed-medicationstatement.html\ngroup SubstitutionStatement(source act : Act, target medicationStatement : MedicationStatement) {\n act -> medicationStatement.extension as ext then {\n act -> ext.url = 'http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-ext-substitution' then {\n // act.code as code -> ext.value = create('CodeableConcept') as valueCC then CECodeableConcept(code, valueCC) "valueCC";\n act.code as actCode -> ext.value = create('CodeableConcept') as valueCC, valueCC.coding as coding then {\n actCode -> coding.system as systemCC, systemCC.value = 'http://terminology.hl7.org/CodeSystem/v3-substanceAdminSubstitution' "system";\n actCode.code as code -> coding.code as codeCC, codeCC.value = code;\n actCode.displayName as display -> coding.display as displayCC, displayCC.value = display "display";\n } "valueCC";\n } "substitutionExtension";\n } "substitutionStatement";\n}\n\n// Number of packages\n// source: https://art-decor.org/art-decor/decor-templates--cdachemed-?id=2.16.756.5.30.1.1.10.4.38\n// target: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationrequest.html\ngroup PrescribedQuantity(source supply : Supply, target medicationRequest : MedicationRequest) {\n supply.quantity as quantity -> medicationRequest.dispenseRequest as dispenseRequest, dispenseRequest.quantity as quant then {\n // IHE-PRE: If the product-element contains package information, the unit attribute is not be present\n quantity.value as value -> quant.value = value;\n // IHE-PRE: If the product-element does not contain package information, the unit attribut is present and the value SHALL be out of the UCUM code system\n quantity.unit as unit then {\n unit -> quant.unit = unit "unit";\n unit -> quant.system = 'http://unitsofmeasure.org' "ucum";\n unit -> quant.code = unit "code";\n };\n };\n}\n\n// source: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.33\n// target: http://build.fhir.org/ig/hl7ch/ch-emed/StructureDefinition-ch-emed-medicationrequest.html\ngroup ManufacturedMaterialEntryContentModuleRequest(source src : SubstanceAdministration, target medicationRequest : MedicationRequest, target medication : Medication) {\n src -> medication.id = 'med', medicationRequest.medication = create('Reference') as vt, vt.reference = '#med' "medication";\n src.consumable as consumable then {\n consumable.manufacturedProduct as manufacturedProduct then {\n manufacturedProduct.manufacturedMaterial as manufacturedMaterial then {\n manufacturedMaterial.name as name where asContent.exists() = false -> medication.code as fhircode, fhircode.text = (%manufacturedMaterial.name.other) "code";\n manufacturedMaterial.asContent as asContent then {\n asContent.containerPackagedMedicine as containerPackagedMedicine then {\n containerPackagedMedicine.code as code -> medication.code as fhircode share medcode then CECodeableConcept(code, fhircode);\n containerPackagedMedicine.name as name -> medication.code as fhircode share medcode then {\n name -> fhircode.text = (%name.other) "text";\n } "text";\n containerPackagedMedicine.formCode as formCode -> medication.form as form then CECodeableConcept(formCode, form);\n // Package size\n containerPackagedMedicine.capacityQuantity as capacityQuantity -> medication.amount = create('Ratio') as ratio, ratio.denominator = create('Quantity') as denominator, denominator.value = '1', denominator.unit = 'Package', denominator.system = 'http://unitsofmeasure.org', denominator.code = '{Package}', ratio.numerator = create('Quantity') as quantity then EmedPQQuantity(capacityQuantity, quantity);\n };\n };\n manufacturedMaterial.ingredient as ingredient -> medication.ingredient as ing then {\n ingredient.quantity as quantity -> ing.strength = create('Ratio') as strength then EmedRTOPQPQRatio(quantity, strength) "strength";\n ingredient.ingredient as medingredient then {\n medingredient.code as code -> ing.item = create('CodeableConcept') as ingcode, ingcode.text = (%medingredient.name.other) then CECodeableConcept(code, ingcode) "ingredientCode";\n };\n };\n };\n };\n // dosage for normal dosing, as no sequences are present there\n src where $this.entryRelationship.sequenceNumber.exists() = false -> medicationRequest.dosageInstruction as dosage then DosageInstructionsStartStopFrequency(src, dosage) "dosage";\n };\n}\n\n// source: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.43\n// target: http://build.fhir.org/ig/hl7ch/ch-emed/StructureDefinition-ch-emed-medicationrequest.html\ngroup PrescriptionItemEntryContentModule(source section : Section, source src : SubstanceAdministration, source patient : Patient, target medicationRequest : MedicationRequest) {\n src.id -> medicationRequest.identifier;\n patient -> medicationRequest.subject = create('Reference') as reference, reference.reference = ('urn:uuid:' + %patient.id) "patient";\n src -> medicationRequest.status = 'completed' "completed";\n src -> medicationRequest.intent = 'order' "order";\n src.text as text then {\n text.reference as reference then {\n reference.value as value -> medicationRequest.extension as ext then NarrativeLink(value, ext) "narrativeLink";\n };\n };\n src -> medicationRequest.contained = create('Medication') as medication then ManufacturedMaterialEntryContentModuleRequest(src, medicationRequest, medication) "medication";\n src.entryRelationship as entry where typeCode = 'RSON' then {\n entry.observation as observation -> medicationRequest.reasonCode as reasonCode then TreatmentReasonEntryContentModule(section, observation, reasonCode) "reasonCode";\n } "41";\n src.entryRelationship as entry where ((typeCode = 'COMP') and (substanceAdministration.templateId.root = '2.16.756.5.30.1.1.10.4.52')) -> medicationRequest.dosageInstruction as dosage then DosageInstructionsNonStructuredEntryContentModule(section, entry, dosage) "52";\n // dosage for split dosing, as sequences are present there\n src.entryRelationship as entry where ((typeCode = 'COMP') and (sequenceNumber.value >= 0)) -> medicationRequest.dosageInstruction as dosage then DosageInstructionsEntryDosageChange(src, entry, dosage) "36";\n src.entryRelationship as entry where ((typeCode = 'REFR') and substanceAdministration.templateId.where(root = '1.3.6.1.4.1.19376.1.9.1.3.10').exists()) -> medicationRequest.extension as ext then MTPReferenceEntryContentModule(entry, ext) "MTPReferenceEntry";\n src.entryRelationship as entry where ((typeCode = 'COMP') and act.templateId.where(root = '2.16.756.5.30.1.1.10.4.2').exists()) then {\n entry.act as act -> medicationRequest.note as note then AnnotationComment(section, act, note) "annotation";\n } "2";\n src.repeatNumber as repeatNumber -> medicationRequest.dispenseRequest as dispenseRequest then {\n repeatNumber.value as val -> dispenseRequest.numberOfRepeatsAllowed = val "repeatNumber";\n } "repeats";\n src.entryRelationship as entry where ((typeCode = 'COMP') and supply.templateId.where(root = '1.3.6.1.4.1.19376.1.9.1.3.8').exists()) then {\n entry.supply as supply -> medicationRequest as medicationRequest then PrescribedQuantity(supply, medicationRequest) "quantity";\n } "8";\n src.entryRelationship as entry where ((typeCode = 'COMP') and act.templateId.where(root = '1.3.6.1.4.1.19376.1.9.1.3.9.1').exists()) then {\n entry.act as act -> medicationRequest as medicationRequest then SubstitutionRequest(act, medicationRequest) "substitution";\n } "1";\n}\n\n// source: https://art-decor.org/art-decor/decor-templates--ch-pharm-?id=2.16.756.5.30.1.1.10.4.35\n// target: http://build.fhir.org/ig/hl7ch/ch-emed/StructureDefinition/ch-emed-dosage-structured-normal\n// dosage for normal dosing, without sequences\ngroup DosageInstructionsStartStopFrequency(source src : SubstanceAdministration, target dosage : Dosage) {\n src as src -> dosage as dosage then EffectiveTimeStartEnd(src, dosage) "effectiveTimeStartEnd";\n src as src -> dosage as dosage then EffectiveTimeWhen(src, dosage) "effectiveTimeWhen";\n src.routeCode as routeCode -> dosage.route as route then CECodeableConcept(routeCode, route);\n src as src -> dosage as dosage then DoseQuantity(src, dosage) "doseQuantity";\n}\n\n// source: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.44\n// target: http://build.fhir.org/ig/hl7ch/ch-emed/StructureDefinition-ch-emed-observation.html\ngroup PharmaceuticalAdviceItemEntryContentModule(source section : Section, source src : Observation, source patient : Patient, target observation : Observation, target bundle : Bundle) {\n src.id -> observation.identifier;\n patient -> observation.subject = create('Reference') as reference, reference.reference = ('urn:uuid:' + %patient.id) "patient";\n src -> observation.status = 'final' "final";\n src.effectiveTime as effectiveTime -> observation.effective = create('dateTime') as value then TSDateTime(effectiveTime, value) "value";\n src.entryRelationship as entry where ((typeCode = 'REFR') and substanceAdministration.templateId.where(root = '1.3.6.1.4.1.19376.1.9.1.3.10').exists()) -> observation.extension as ext then MTPReferenceEntryContentModule(entry, ext) "MTPReferenceEntry";\n src.entryRelationship as entry where ((typeCode = 'REFR') and substanceAdministration.templateId.where(root = '1.3.6.1.4.1.19376.1.9.1.3.7').exists()) -> bundle.entry as e, e.id = uuid() as uuid, e.fullUrl = append('urn:uuid:', uuid), e.resource = create('MedicationStatement') as medicationstatement, observation.extension as ext, ext.url = 'http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-ext-medicationstatement-changed', ext.value = create('Reference') as reference, reference.reference = append('urn:uuid:', uuid) then {\n entry.substanceAdministration as substanceAdministration then MedicationTreatmentPlanItemEntryContentModule(section, substanceAdministration, patient, medicationstatement);\n } "cdaEntry";\n src.text as text -> observation.note as note then {\n text.data as data -> note.text = data "level3observation";\n text where (data.exists() = false) -> note.text = (%section.text.substring(%section.text.indexOf(%src.text.reference.value.substring(1))).substring(%section.text.substring(%section.text.indexOf(%src.text.reference.value.substring(1))).indexOf('>') + 1, %section.text.substring(%section.text.indexOf(%src.text.reference.value.substring(1))).indexOf('<') - %section.text.substring(%section.text.indexOf(%src.text.reference.value.substring(1))).indexOf('>') - 1)) "idRef";\n text.reference as reference then {\n reference.value as value -> note.extension as ext then NarrativeLink(value, ext) "narrativeLink";\n };\n } "note";\n src.code -> observation.code;\n}\n\n// _________________________ Template Type not specified _________________________\n// target: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-ext-treatmentplan.html\ngroup InnerExtensionExternalDocumentId(source src, target ext : Extension) {\n src -> ext.url = 'externalDocumentId' "url";\n src -> ext.value = create('Identifier') as id then II(src, id) "value";\n}\n\n// target: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-ext-treatmentplan.html\ngroup InnerExtensionId(source src, target ext : Extension) {\n src -> ext.url = 'id' "url";\n src -> ext.value = create('Identifier') as id then II(src, id) "value";\n}\n\n</pre>\n </div>"
},
"url" : "http://fhir.ch/ig/cda-fhir-maps/StructureMap/CdaChEmedToBundle",
"version" : "0.3.0",
"name" : "CdaChEmedToBundle",
"status" : "draft",
"date" : "2022-02-11T11:14:39+01:00",
"publisher" : "ahdis",
"contact" : [
{
"name" : "ahdis",
"telecom" : [
{
"system" : "url",
"value" : "http://www.ahdis.ch/"
}
]
}
],
"description" : "Medication Entries 2020-10-30 Oliver Egger, copyright ahdis ag, Apache License CDA-CH-EMED: https://art-decor.org/art-decor/decor-project--cdachemed- FHIR CH-EMED: http://fhir.ch/ig/ch-emed/index.html",
"copyright" : "CC-BY-SA-4.0",
"structure" : [
{
"url" : "http://hl7.org/fhir/cda/StructureDefinition/ClinicalDocument",
"mode" : "source",
"alias" : "ClinicalDocument"
},
{
"url" : "http://hl7.org/fhir/cda/StructureDefinition/AssignedAuthor",
"mode" : "source",
"alias" : "AssignedAuthor"
},
{
"url" : "http://hl7.org/fhir/cda/StructureDefinition/AssignedEntity",
"mode" : "source",
"alias" : "AssignedEntity"
},
{
"url" : "http://hl7.org/fhir/cda/StructureDefinition/Author",
"mode" : "source",
"alias" : "Author"
},
{
"url" : "http://hl7.org/fhir/cda/StructureDefinition/CustodianOrganization",
"mode" : "source",
"alias" : "CustodianOrganization"
},
{
"url" : "http://hl7.org/fhir/cda/StructureDefinition/IVL_TS",
"mode" : "source",
"alias" : "IVL_TS"
},
{
"url" : "http://hl7.org/fhir/cda/StructureDefinition/EIVL_TS",
"mode" : "source",
"alias" : "EIVL_TS"
},
{
"url" : "http://hl7.org/fhir/cda/StructureDefinition/Observation",
"mode" : "source",
"alias" : "Observation"
},
{
"url" : "http://hl7.org/fhir/cda/StructureDefinition/PatientRole",
"mode" : "source",
"alias" : "PatientRole"
},
{
"url" : "http://hl7.org/fhir/cda/StructureDefinition/RecordTarget",
"mode" : "source",
"alias" : "RecordTarget"
},
{
"url" : "http://hl7.org/fhir/cda/StructureDefinition/Section",
"mode" : "source",
"alias" : "Section"
},
{
"url" : "http://hl7.org/fhir/cda/StructureDefinition/SubstanceAdministration",
"mode" : "source",
"alias" : "SubstanceAdministration"
},
{
"url" : "http://hl7.org/fhir/cda/StructureDefinition/SXPR_TS",
"mode" : "source",
"alias" : "SXPR_TS"
},
{
"url" : "http://hl7.org/fhir/StructureDefinition/Bundle",
"mode" : "target",
"alias" : "Bundle"
},
{
"url" : "http://hl7.org/fhir/StructureDefinition/Composition",
"mode" : "produced",
"alias" : "Composition"
},
{
"url" : "http://hl7.org/fhir/StructureDefinition/Patient",
"mode" : "produced",
"alias" : "Patient"
},
{
"url" : "http://hl7.org/fhir/StructureDefinition/Practitioner",
"mode" : "produced",
"alias" : "Practitioner"
},
{
"url" : "http://hl7.org/fhir/StructureDefinition/Organization",
"mode" : "produced",
"alias" : "Organization"
},
{
"url" : "http://hl7.org/fhir/StructureDefinition/MedicationStatement",
"mode" : "produced",
"alias" : "MedicationStatement"
},
{
"url" : "http://hl7.org/fhir/StructureDefinition/Dosage",
"mode" : "produced",
"alias" : "Dosage"
},
{
"url" : "http://hl7.org/fhir/StructureDefinition/Observation",
"mode" : "produced",
"alias" : "Observation"
}
],
"import" : [
"http://fhir.ch/ig/cda-fhir-maps/StructureMap/CdaToFhirTypes",
"http://fhir.ch/ig/cda-fhir-maps/StructureMap/CdaToBundle",
"http://fhir.ch/ig/cda-fhir-maps/StructureMap/CdaChToBundle"
],
"group" : [
{
"name" : "AnnotationComment",
"typeMode" : "none",
"documentation" : "source: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.2 target: Annotation note (e.g. http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationstatement.html)",
"input" : [
{
"name" : "section",
"type" : "Section",
"mode" : "source"
},
{
"name" : "act",
"type" : "Act",
"mode" : "source"
},
{
"name" : "note",
"type" : "Annotation",
"mode" : "target"
}
],
"rule" : [
{
"name" : "text",
"source" : [
{
"context" : "act",
"element" : "text",
"variable" : "text"
}
],
"rule" : [
{
"name" : "level3",
"source" : [
{
"context" : "text",
"element" : "data",
"variable" : "data"
}
],
"target" : [
{
"context" : "note",
"contextType" : "variable",
"element" : "text",
"transform" : "copy",
"parameter" : [
{
"valueId" : "data"
}
]
}
]
},
{
"name" : "reference",
"source" : [
{
"context" : "text",
"element" : "reference",
"variable" : "reference"
}
],
"rule" : [
{
"name" : "narrativeLink",
"source" : [
{
"context" : "reference",
"element" : "value",
"variable" : "value"
}
],
"target" : [
{
"context" : "note",
"contextType" : "variable",
"element" : "extension",
"variable" : "ext"
}
],
"dependent" : [
{
"name" : "NarrativeLink",
"variable" : [
"value",
"ext"
]
}
]
}
]
}
]
}
]
},
{
"name" : "ManufacturedMaterialEntryContentModuleDispense",
"typeMode" : "none",
"documentation" : "source: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.33 target: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationdispense.html",
"input" : [
{
"name" : "src",
"type" : "Supply",
"mode" : "source"
},
{
"name" : "medicationDispense",
"type" : "MedicationDispense",
"mode" : "target"
},
{
"name" : "medication",
"type" : "Medication",
"mode" : "target"
}
],
"rule" : [
{
"name" : "medication",
"source" : [
{
"context" : "src"
}
],
"target" : [
{
"context" : "medication",
"contextType" : "variable",
"element" : "id",
"transform" : "copy",
"parameter" : [
{
"valueString" : "med"
}
]
},
{
"context" : "medicationDispense",
"contextType" : "variable",
"element" : "medication",
"variable" : "vt",
"transform" : "create",
"parameter" : [
{
"valueString" : "Reference"
}
]
},
{
"context" : "vt",
"contextType" : "variable",
"element" : "reference",
"transform" : "copy",
"parameter" : [
{
"valueString" : "#med"
}
]
}
]
},
{
"name" : "quantity",
"source" : [
{
"context" : "src",
"element" : "quantity",
"variable" : "quantity"
}
],
"target" : [
{
"context" : "medicationDispense",
"contextType" : "variable",
"element" : "quantity",
"variable" : "medDispQuantity"
}
],
"rule" : [
{
"name" : "value",
"source" : [
{
"context" : "quantity",
"element" : "value",
"variable" : "value"
}
],
"target" : [
{
"context" : "medDispQuantity",
"contextType" : "variable",
"element" : "value",
"transform" : "copy",
"parameter" : [
{
"valueId" : "value"
}
]
}
],
"documentation" : "IHE-DIS: If the product-element contains package information, the unit attribute is not be present"
},
{
"name" : "unit",
"source" : [
{
"context" : "quantity",
"element" : "unit",
"variable" : "unit"
}
],
"rule" : [
{
"name" : "unit",
"source" : [
{
"context" : "unit"
}
],
"target" : [
{
"context" : "medDispQuantity",
"contextType" : "variable",
"element" : "unit",
"transform" : "copy",
"parameter" : [
{
"valueId" : "unit"
}
]
}
]
},
{
"name" : "ucum",
"source" : [
{
"context" : "unit"
}
],
"target" : [
{
"context" : "medDispQuantity",
"contextType" : "variable",
"element" : "system",
"transform" : "copy",
"parameter" : [
{
"valueString" : "http://unitsofmeasure.org"
}
]
}
]
},
{
"name" : "code",
"source" : [
{
"context" : "unit"
}
],
"target" : [
{
"context" : "medDispQuantity",
"contextType" : "variable",
"element" : "code",
"transform" : "copy",
"parameter" : [
{
"valueId" : "unit"
}
]
}
]
}
],
"documentation" : "IHE-DIS: If the product-element does not contain package information, the unit attribut is present and the value SHALL be out of the UCUM code system"
}
],
"documentation" : "quantity value (number of packages)"
},
{
"name" : "product",
"source" : [
{
"context" : "src",
"element" : "product",
"variable" : "product"
}
],
"rule" : [
{
"name" : "manufacturedProduct",
"source" : [
{
"context" : "product",
"element" : "manufacturedProduct",
"variable" : "manufacturedProduct"
}
],
"rule" : [
{
"name" : "manufacturedMaterial",
"source" : [
{
"context" : "manufacturedProduct",
"element" : "manufacturedMaterial",
"variable" : "manufacturedMaterial"
}
],
"rule" : [
{
"name" : "medication.code",
"source" : [
{
"context" : "manufacturedMaterial",
"element" : "name",
"variable" : "name",
"condition" : "asContent.exists() = false"
}
],
"target" : [
{
"context" : "medication",
"contextType" : "variable",
"element" : "code",
"variable" : "fhircode"
},
{
"context" : "fhircode",
"contextType" : "variable",
"element" : "text",
"transform" : "evaluate",
"parameter" : [
{
"valueString" : "%manufacturedMaterial.name.other"
}
]
}
]
},
{
"name" : "asContent",
"source" : [
{
"context" : "manufacturedMaterial",
"element" : "asContent",
"variable" : "asContent"
}
],
"rule" : [
{
"name" : "containerPackagedMedicine",
"source" : [
{
"context" : "asContent",
"element" : "containerPackagedMedicine",
"variable" : "containerPackagedMedicine"
}
],
"rule" : [
{
"name" : "medication.code",
"source" : [
{
"context" : "containerPackagedMedicine",
"element" : "code",
"variable" : "code"
}
],
"target" : [
{
"context" : "medication",
"contextType" : "variable",
"element" : "code",
"variable" : "fhircode",
"listMode" : [
"share"
],
"listRuleId" : "medcode"
}
],
"dependent" : [
{
"name" : "CECodeableConcept",
"variable" : [
"code",
"fhircode"
]
}
]
},
{
"name" : "code.text",
"source" : [
{
"context" : "containerPackagedMedicine",
"element" : "name",
"variable" : "name"
}
],
"target" : [
{
"context" : "medication",
"contextType" : "variable",
"element" : "code",
"variable" : "fhircode",
"listMode" : [
"share"
],
"listRuleId" : "medcode"
}
],
"rule" : [
{
"name" : "medication.code.text",
"source" : [
{
"context" : "name"
}
],
"target" : [
{
"context" : "fhircode",
"contextType" : "variable",
"element" : "text",
"transform" : "evaluate",
"parameter" : [
{
"valueString" : "%name.other"
}
]
}
]
}
]
},
{
"name" : "medication.formCode",
"source" : [
{
"context" : "containerPackagedMedicine",
"element" : "formCode",
"variable" : "formCode"
}
],
"target" : [
{
"context" : "medication",
"contextType" : "variable",
"element" : "form",
"variable" : "form"
}
],
"dependent" : [
{
"name" : "CECodeableConcept",
"variable" : [
"formCode",
"form"
]
}
]
},
{
"name" : "capacityQuantity",
"source" : [
{
"context" : "containerPackagedMedicine",
"element" : "capacityQuantity",
"variable" : "capacityQuantity"
}
],
"target" : [
{
"context" : "medication",
"contextType" : "variable",
"element" : "amount",
"variable" : "ratio",
"transform" : "create",
"parameter" : [
{
"valueString" : "Ratio"
}
]
},
{
"context" : "ratio",
"contextType" : "variable",
"element" : "denominator",
"variable" : "denominator",
"transform" : "create",
"parameter" : [
{
"valueString" : "Quantity"
}
]
},
{
"context" : "denominator",
"contextType" : "variable",
"element" : "value",
"transform" : "copy",
"parameter" : [
{
"valueString" : "1"
}
]
},
{
"context" : "denominator",
"contextType" : "variable",
"element" : "unit",
"transform" : "copy",
"parameter" : [
{
"valueString" : "Package"
}
]
},
{
"context" : "denominator",
"contextType" : "variable",
"element" : "system",
"transform" : "copy",
"parameter" : [
{
"valueString" : "http://unitsofmeasure.org"
}
]
},
{
"context" : "denominator",
"contextType" : "variable",
"element" : "code",
"transform" : "copy",
"parameter" : [
{
"valueString" : "{Package}"
}
]
},
{
"context" : "ratio",
"contextType" : "variable",
"element" : "numerator",
"variable" : "quantity",
"transform" : "create",
"parameter" : [
{
"valueString" : "Quantity"
}
]
}
],
"dependent" : [
{
"name" : "EmedPQQuantity",
"variable" : [
"capacityQuantity",
"quantity"
]
}
],
"documentation" : "Package size"
}
]
}
]
},
{
"name" : "ingredient",
"source" : [
{
"context" : "manufacturedMaterial",
"element" : "ingredient",
"variable" : "ingredient"
}
],
"target" : [
{
"context" : "medication",
"contextType" : "variable",
"element" : "ingredient",
"variable" : "ing"
}
],
"rule" : [
{
"name" : "strength",
"source" : [
{
"context" : "ingredient",
"element" : "quantity",
"variable" : "quantity"
}
],
"target" : [
{
"context" : "ing",
"contextType" : "variable",
"element" : "strength",
"variable" : "strength",
"transform" : "create",
"parameter" : [
{
"valueString" : "Ratio"
}
]
}
],
"dependent" : [
{
"name" : "EmedRTOPQPQRatio",
"variable" : [
"quantity",
"strength"
]
}
]
},
{
"name" : "ingredient.ingredient",
"source" : [
{
"context" : "ingredient",
"element" : "ingredient",
"variable" : "medingredient"
}
],
"rule" : [
{
"name" : "ingredientCode",
"source" : [
{
"context" : "medingredient",
"element" : "code",
"variable" : "code"
}
],
"target" : [
{
"context" : "ing",
"contextType" : "variable",
"element" : "item",
"variable" : "ingcode",
"transform" : "create",
"parameter" : [
{
"valueString" : "CodeableConcept"
}
]
},
{
"context" : "ingcode",
"contextType" : "variable",
"element" : "text",
"transform" : "evaluate",
"parameter" : [
{
"valueString" : "%medingredient.name.other"
}
]
}
],
"dependent" : [
{
"name" : "CECodeableConcept",
"variable" : [
"code",
"ingcode"
]
}
]
}
]
}
]
}
]
}
]
},
{
"name" : "entry",
"source" : [
{
"context" : "src",
"element" : "entryRelationship",
"variable" : "entry"
}
],
"rule" : [
{
"name" : "substanceAdministration",
"source" : [
{
"context" : "entry",
"element" : "substanceAdministration",
"variable" : "substanceAdministration"
}
],
"rule" : [
{
"name" : "dosage",
"source" : [
{
"context" : "substanceAdministration",
"condition" : "$this.entryRelationship.sequenceNumber.exists() = false"
}
],
"target" : [
{
"context" : "medicationDispense",
"contextType" : "variable",
"element" : "dosageInstruction",
"variable" : "dosage"
}
],
"dependent" : [
{
"name" : "DosageInstructionsStartStopFrequency",
"variable" : [
"substanceAdministration",
"dosage"
]
}
]
}
]
}
],
"documentation" : "dosage for normal dosing, as no sequences are present there"
}
]
}
]
},
{
"name" : "EmedPQQuantity",
"typeMode" : "none",
"input" : [
{
"name" : "src",
"type" : "PQ",
"mode" : "source"
},
{
"name" : "tgt",
"type" : "Quantity",
"mode" : "target"
}
],
"rule" : [
{
"name" : "value",
"source" : [
{
"context" : "src",
"element" : "value",
"variable" : "value"
}
],
"target" : [
{
"context" : "tgt",
"contextType" : "variable",
"element" : "value",
"transform" : "copy",
"parameter" : [
{
"valueId" : "value"
}
]
}
]
},
{
"name" : "unit",
"source" : [
{
"context" : "src",
"element" : "unit",
"variable" : "unit"
}
],
"target" : [
{
"context" : "tgt",
"contextType" : "variable",
"element" : "code",
"transform" : "copy",
"parameter" : [
{
"valueId" : "unit"
}
]
}
]
},
{
"name" : "unit",
"source" : [
{
"context" : "src",
"element" : "unit",
"variable" : "unit"
}
],
"target" : [
{
"context" : "tgt",
"contextType" : "variable",
"element" : "system",
"transform" : "evaluate",
"parameter" : [
{
"valueString" : "'http://fhir.ch/ig/ch-emed/ValueSet/UnitCode'.resolve().compose.include.where(concept.where(code = %unit)).system"
}
]
}
]
},
{
"name" : "unit",
"source" : [
{
"context" : "src",
"element" : "unit",
"variable" : "unit"
}
],
"target" : [
{
"context" : "tgt",
"contextType" : "variable",
"element" : "unit",
"transform" : "evaluate",
"parameter" : [
{
"valueString" : "'http://fhir.ch/ig/ch-emed/ValueSet/UnitCode'.resolve().compose.include.concept.where(code = %unit).display"
}
]
}
]
}
]
},
{
"name" : "EmedRTOPQPQRatio",
"typeMode" : "none",
"input" : [
{
"name" : "src",
"type" : "RTO_PQ_PQ",
"mode" : "source"
},
{
"name" : "tgt",
"type" : "Ratio",
"mode" : "target"
}
],
"rule" : [
{
"name" : "numerator",
"source" : [
{
"context" : "src",
"element" : "numerator",
"variable" : "numerator"
}
],
"target" : [
{
"context" : "tgt",
"contextType" : "variable",
"element" : "numerator",
"variable" : "targetNumerator"
}
],
"dependent" : [
{
"name" : "EmedPQQuantity",
"variable" : [
"numerator",
"targetNumerator"
]
}
]
},
{
"name" : "denominator",
"source" : [
{
"context" : "src",
"element" : "denominator",
"variable" : "denominator"
}
],
"target" : [
{
"context" : "tgt",
"contextType" : "variable",
"element" : "denominator",
"variable" : "targetDenominator"
}
],
"dependent" : [
{
"name" : "EmedPQQuantity",
"variable" : [
"denominator",
"targetDenominator"
]
}
]
}
]
},
{
"name" : "ManufacturedMaterialEntryContentModuleStatement",
"typeMode" : "none",
"documentation" : "source: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.33 target: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationstatement.html",
"input" : [
{
"name" : "src",
"type" : "SubstanceAdministration",
"mode" : "source"
},
{
"name" : "medicationStatement",
"type" : "MedicationStatement",
"mode" : "target"
},
{
"name" : "medication",
"type" : "Medication",
"mode" : "target"
}
],
"rule" : [
{
"name" : "medication",
"source" : [
{
"context" : "src"
}
],
"target" : [
{
"context" : "medication",
"contextType" : "variable",
"element" : "id",
"transform" : "copy",
"parameter" : [
{
"valueString" : "med"
}
]
},
{
"context" : "medicationStatement",
"contextType" : "variable",
"element" : "medication",
"variable" : "vt",
"transform" : "create",
"parameter" : [
{
"valueString" : "Reference"
}
]
},
{
"context" : "vt",
"contextType" : "variable",
"element" : "reference",
"transform" : "copy",
"parameter" : [
{
"valueString" : "#med"
}
]
}
]
},
{
"name" : "consumable",
"source" : [
{
"context" : "src",
"element" : "consumable",
"variable" : "consumable"
}
],
"rule" : [
{
"name" : "manufacturedProduct",
"source" : [
{
"context" : "consumable",
"element" : "manufacturedProduct",
"variable" : "manufacturedProduct"
}
],
"rule" : [
{
"name" : "manufacturedMaterial",
"source" : [
{
"context" : "manufacturedProduct",
"element" : "manufacturedMaterial",
"variable" : "manufacturedMaterial"
}
],
"rule" : [
{
"name" : "medication.code",
"source" : [
{
"context" : "manufacturedMaterial",
"element" : "name",
"variable" : "name",
"condition" : "asContent.exists() = false"
}
],
"target" : [
{
"context" : "medication",
"contextType" : "variable",
"element" : "code",
"variable" : "fhircode"
},
{
"context" : "fhircode",
"contextType" : "variable",
"element" : "text",
"transform" : "evaluate",
"parameter" : [
{
"valueString" : "%manufacturedMaterial.name.other"
}
]
}
]
},
{
"name" : "asContent",
"source" : [
{
"context" : "manufacturedMaterial",
"element" : "asContent",
"variable" : "asContent"
}
],
"rule" : [
{
"name" : "containerPackagedMedicine",
"source" : [
{
"context" : "asContent",
"element" : "containerPackagedMedicine",
"variable" : "containerPackagedMedicine"
}
],
"rule" : [
{
"name" : "medication.code",
"source" : [
{
"context" : "containerPackagedMedicine",
"element" : "code",
"variable" : "code"
}
],
"target" : [
{
"context" : "medication",
"contextType" : "variable",
"element" : "code",
"variable" : "fhircode",
"listMode" : [
"share"
],
"listRuleId" : "medcode"
}
],
"dependent" : [
{
"name" : "CECodeableConcept",
"variable" : [
"code",
"fhircode"
]
}
]
},
{
"name" : "code.text",
"source" : [
{
"context" : "containerPackagedMedicine",
"element" : "name",
"variable" : "name"
}
],
"target" : [
{
"context" : "medication",
"contextType" : "variable",
"element" : "code",
"variable" : "fhircode",
"listMode" : [
"share"
],
"listRuleId" : "medcode"
}
],
"rule" : [
{
"name" : "medication.code.text",
"source" : [
{
"context" : "name"
}
],
"target" : [
{
"context" : "fhircode",
"contextType" : "variable",
"element" : "text",
"transform" : "evaluate",
"parameter" : [
{
"valueString" : "%name.other"
}
]
}
]
}
]
},
{
"name" : "medication.formCode",
"source" : [
{
"context" : "containerPackagedMedicine",
"element" : "formCode",
"variable" : "formCode"
}
],
"target" : [
{
"context" : "medication",
"contextType" : "variable",
"element" : "form",
"variable" : "form"
}
],
"dependent" : [
{
"name" : "CECodeableConcept",
"variable" : [
"formCode",
"form"
]
}
]
},
{
"name" : "capacityQuantity",
"source" : [
{
"context" : "containerPackagedMedicine",
"element" : "capacityQuantity",
"variable" : "capacityQuantity"
}
],
"target" : [
{
"context" : "medication",
&nbs